<template>
	<view class="content">
		<view class="main">

			<view class="menu_name">友好提醒</view>
			<view style="display: flex;align-items: center;">
				<input class="et_wb_num" placeholder="手机号码待输入..." maxlength="50" :value="order_sn" @input="onInputOrder" />
				<!-- <view class="btn_wb" @click="onQueryWb">扫查单码</view> -->
			</view>

			<view class="mobile_div">
				<view v-for="(item,index) in mobile_list" class="item_mobile" @click="onMobile(item)">
					{{item.mobile}}
				</view>
			</view>

			<view class="btn_ok" @click="onOk">呼叫</view>

			<!-- <view v-if="res" style="margin: 24rpx 0 0 0;">呼叫结果：{{res}}</view> -->
			<rich-text style="margin: 24rpx 0 0 0" :nodes="res"></rich-text>

		</view>


	</view>
</template>

<script>
	import { getUInfo, isEmpty } from '@/util/util.js'
	import { chooseAndUploadImg, chooseAndUploadVideo } from '@/util/uni_util.js'
	export default {
		data() {
			return {
				// 运单号
				order_sn: '',
				// 手机号列表
				mobile_list: [
					{ name: 'OO', mobile: '15266661291' },
					{ name: 'OO', mobile: '13615312304' },
					{ name: 'OO', mobile: '13791008969' },
				],
				// 响应数据
				res: {},
			}
		},

		onLoad(opts) {
			// 扫码
			uni.$on('onGetQrCode', (data) => {
				let { qr_code, od_num, startCity, toCity, goods } = JSON.parse(data.qr_code_data)
				this.order_sn = od_num
				this.query_num = qr_code
				this.detail = { startCity, toCity, goods }
				console.log('this.detail  = ', this.detail);
			})
			this.order_sn = this.mobile_list[0].mobile
		},

		onUnload() {
			uni.$off('onGetQrCode', () => {})
		},

		methods: {
			// 点击手机号
			onMobile(item) {
				this.order_sn = item.mobile
			},
			// 监听:输入单号
			onInputOrder(e) {
				this.order_sn = e.detail.value
				if (!this.order_sn) {
					this.detail = {}
				}
			},

			// 呼叫
			onOk() {
				if (!this.order_sn) {
					uni.showToast({ icon: 'none', title: '手机号必填' })
					return
				}

				let content = '呼叫这个XX？'
				if (this.order_sn == '13615312304' || this.order_sn == '13791008969') {
					content = `呼叫${this.order_sn}？`
				}
				uni.showModal({
					title: '提示',
					content,
					success: (res) => {
						res.confirm && this.postData()
					}
				})
			},

			// 接口:提交数据
			async postData() {
				let that = this
				uni.showLoading({ title: '呼叫中..', mask: true, })
				let account = 'V38604573'
				let password = '95d0b76614024004f09283b778b53f66'
				let mobile = this.order_sn
				let content = '520520'
				let format = 'json'
				let res = await that.$sendVoiceCode({ account, password, mobile, content, format })
				if (res) {
					this.res = JSON.stringify(res)
				} else {
					uni.showToast({ title: res.msg, icon: 'none' })
				}
			},

		}
	}
</script>

<style scoped>
	.content {
		display: flex;
		flex-direction: column;
		position: relative;
		min-height: 100vh;
		background-color: #6974DD;
		/* background-color: #f0f0f0; */
	}

	.mobile_div {
		display: flex;
		flex-wrap: wrap;
		margin: 24rpx 0 0 0;
	}

	.item_mobile {
		margin: 0 8rpx 0 0rpx;
		font-size: 28rpx;
		font-weight: bold;
		color: deepskyblue;
	}

	.main {
		display: flex;
		flex-direction: column;
		margin: 24rpx;
		background-color: white;
		border-radius: 24rpx;
		padding: 24rpx;
	}

	.menu_name {
		margin: 36rpx 0 0 0;
		display: flex;
		align-items: center;
	}

	.et_wb_num {
		flex-grow: 1;
		height: 76rpx;
		line-height: 76rpx;
		border-radius: 12rpx;
		border: solid 1rpx #ccc;
		margin: 24rpx 0 0 0;
		padding: 0 24rpx 0 24rpx;
	}

	.btn_wb {
		width: 25%;
		height: 76rpx;
		line-height: 76rpx;
		color: white;
		text-align: center;
		font-size: 28rpx;
		margin: 24rpx 0 0 0;
		border-radius: 12rpx;
		background: #6974DD;
		margin: 24rpx 0 0 12rpx;
	}

	.btn_ok {
		height: 88rpx;
		line-height: 88rpx;
		color: white;
		text-align: center;
		font-size: 30rpx;
		margin: 60rpx 0 0 0;
		border-radius: 888rpx;
		background: #6974DD;
	}
</style>